//
//  PaperHardStarView.m
//  智云题库
//
//  Created by 毕武侠 on 2017/3/20.
//  Copyright © 2017年 bwx. All rights reserved.
//

#import "PaperHardStarView.h"

@interface PaperHardStarView ()

@property (nonatomic, strong) NSMutableArray *stars;

@end

@implementation PaperHardStarView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupConfigure];
    }
    return self;
}

- (void)setupConfigure {
    self.stars = [NSMutableArray arrayWithCapacity:5];
    
    CGFloat x = 0;
    //创建🌟imageView
    for (int i = 0; i < 6; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(x, 3, 18, 18)];
        imageView.image = [UIImage imageNamed:@"PaperStarColor"];
        imageView.tag = 10 + i;
        [self addSubview:imageView];
        [self.stars addObject:imageView];
        x = imageView.right + 4;
    }
}

- (void)setIndex:(NSUInteger)index {
    _index = index;
    for (int i = 0; i < 6; i++) {
        NSUInteger maxIndex = (index + 1) * 2;
        UIImageView *imageView = [self viewWithTag:10 + i];
        if (imageView.tag < 10 + maxIndex) {
            imageView.image = [UIImage imageNamed:@"PaperStarColor"];
        } else {
            imageView.image = [UIImage imageNamed:@"PaperStarGray"];
        }
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
